namespace Defiant.SqlServer.PowerShellScriptTask
{
    using System;
    using System.Globalization;
    using System.Management.Automation.Host;
    using Microsoft.SqlServer.Dts.Runtime;

    internal class ScriptHost : PSHost
    {
        private readonly CultureInfo originalCulture = System.Threading.Thread.CurrentThread.CurrentCulture;
        private readonly CultureInfo originalUiCulture = System.Threading.Thread.CurrentThread.CurrentUICulture;
        private readonly Guid instanceId = Guid.NewGuid();
        private readonly ScriptHostInterface scriptHostInterface;

        internal ScriptHost(IDTSComponentEvents componentEvents)
        {
            this.scriptHostInterface = new ScriptHostInterface(componentEvents);
        }

        public override Guid InstanceId
        {
            get { return this.instanceId; }
        }

        public override string Name
        {
            get { return "ScriptHost"; }
        }

        public override CultureInfo CurrentCulture
        {
            get { return this.originalCulture; }
        }

        public override CultureInfo CurrentUICulture
        {
            get { return this.originalUiCulture; }
        }

        public override PSHostUserInterface UI
        {
            get { return this.scriptHostInterface; }
        }

        public override Version Version
        {
            get { return new Version(1, 0, 0, 0); }
        }

        public override void EnterNestedPrompt()
        {
            throw new NotImplementedException("The method or operation is not implemented.");
        }

        public override void ExitNestedPrompt()
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public override void NotifyBeginApplication()
        {
        }

        public override void NotifyEndApplication()
        {
        }

        public override void SetShouldExit(int exitCode)
        {
        }
    }
}
